<template>
	<view>
		<view class="u-p-20 ">
			<view class="bg_FFFFFF u-p-10 u-b-r-10">
				<u-input type="select" v-model="params.date" @click="timeShow=true" placeholder="请选择日期"></u-input>
			</view>
			<view class="bs_CCCCCC bg_FFFFFF u-p-20 u-m-t-20 u-b-r-10" v-for="(item,index) in list" :key="index">
				<view class="u-p-20 u-flex u-row-between" @click="$u.route(`${item.type==1?`/pages/home/paymassage?num=${item.spu}`:`/pages/home/shopmassage?num=${item.spu}`}`)">
					<view class="u-flex">
						<view class="">
							<u-image :src='item.img_url' width='183rpx' height='183rpx'></u-image>
						</view>
						<view class="u-p-l-10 ">
							<view class="u-weight">{{item.name}}</view>
							<view class=" u-p-t-10" style="color: #FC3533;">￥{{item.price}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-picker mode="time" v-model="timeShow" @confirm="timeFirm" @cancel="timeCancel"></u-picker>
		<!-- 加载更多 -->
		<u-loadmore :status="status" icon-type="circle" margin-top="20" margin-bottom="20" />
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				params: {
					page: 1,
					page_size: 20,
					date:''
				},
				timeShow:false,
				status: 'loadmore',
			}
		},
		onLoad(obj) {
			
		},
		onShow() {
			this.clear()
			this.my_history()
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			if (this.list.length >= 20) {
				this.my_history();
			}
		},
		methods: {
			timeFirm(e){
				this.params.date=`${e.year}-${e.month}-${e.day}`
				this.clear()
				this.my_history()
			},
			timeCancel(){
				this.params.date=''
				this.clear()
				this.my_history()
			},
			clear(){
				this.list=[]
				this.params.page=1
			},
			my_history() {
				this.$api.my_history(this.params, res => {
					if (res.data.code == 1) {
						if (res.data.data.data.length < 20) {
							this.status = 'nomore';
						} else {
							this.params.page = this.params.page + 1;
							this.status = 'loadmore';
						}
						this.list = this.list.concat(res.data.data.data);
						uni.stopPullDownRefresh();
					}
				})
			}
		}
	}
</script>

<style scoped>
	page {
		background: #f5f5f5;
	}

	.bgc {
		background: #F4F4F4;
	}

	.bgc1 {
		background: #FFF2F2;
		border: 1rpx solid #FC3533;
	}

	.ones {
		width: 503rpx;
		height: 883rpx;
		background: url('https://www.sqkjkj.vip/wxImg/mybag/img5.png') no-repeat;
		background-size: 100% 100%;
	}

	.error {
		width: 74rpx;
		height: 160rpx;
		background: url('https://www.sqkjkj.vip/wxImg/common/home/img12.png') no-repeat;
		background-size: 100% 100%;
	}
</style>
